@extends('layouts.header')
@inject('sender','App\Http\Controllers\WroteitController')
@section('content')
    <h2 style="text-align: center;">Outbox - New message</h2>
    <!-- Show any validation errors, in case they exist -->
    @if ($errors->any())
    <div class="alert alert-danger">
        <ul>
            @foreach ($errors->all() as $error)
                <li style="color: red;">{{ $error }}</li>
            @endforeach
        </ul>
    </div>
    @endif
    <!-- Forms for new message -->
    <form action="{{ route('store_new_message') }}" method="POST" style="text-align: center;">
        {{ csrf_field() }}

        <div class="form-group">
            <label for="from_id">From: </label><input type="text" style="width: 1213px;" name="from_id" placeholder="{{ Auth::user()->name }}" readonly='true' disabled>
            <input type="hidden" name="from_id" value="{{ Auth::user()->id }}"><br /><br />
        </div>

        <div class="form-group">
            <label for="to_id">To: </label>
            <select name="to_id" style="width: 1237px;" class="form_control">
            @foreach($users as $user)
                <option value="{{ $user->id }}"> {{ $user->name }}</option>
            @endforeach
            </select><br /><br />
        </div>

        <div class="form-group">
            <label for="subject">Subject: </label><input type="text" style="width: 1200px;" name="title" class="input" value="{{ old('title')}}" /><br /><br />
        </div>

        <div class="form-group">
            <textarea rows="29" cols="155" name="body" class="form_control"/></textarea><br /><br />
        </div>

        <div class="form-group">
            <input type="hidden" name="created_at" value="{{$sender::getCurrentTimeStamp()}}">
            <input type="hidden" name="updated_at" value="{{$sender::getCurrentTimeStamp()}}">
            <button type="submit" class='btn btn-primary'>Send message</button>
        </div>

    </form>
@endsection()